﻿using System.Collections.Generic;

/// <summary>
/// 聊天房间
/// </summary>
public class Room : ChatObject
{
    public int MemberCount { get; set; }
    public override bool Equals(object obj)
    {
        if (obj == null || !(obj is Room))
            return false;
        if (obj == this)
            return true;
        return ((Room)obj).MemberCount == MemberCount && base.Equals(obj);
    }
    public override int GetHashCode()
    {
        return base.GetHashCode();
    }
}

/// <summary>
/// 房间比较器，比较两个房间是否完全相等
/// </summary>
public class RoomComparer : IEqualityComparer<Room>
{
    public bool Equals(Room x, Room y)
    {
        if (x == null && y == null)
            return true;
        else if (x == null || y == null)
            return false;
        else
        {
            if (x.Equals(y))
                return true;
            return false;
        }
    }
    public int GetHashCode(Room obj)
    {     
        return obj.GetHashCode();
    }
}
/// <summary>
/// 两个房间Id一样则返回真
/// </summary>
public class RoomIdComparer : IEqualityComparer<Room>
{
    public bool Equals(Room x, Room y)
    {
        if (x == null && y == null)
            return true;
        else if (x == null || y == null)
            return false;
        else
        {
            if (x.Id == y.Id)
                return true;
            return false;
        }
    }
    public int GetHashCode(Room obj)
    {
        return obj.GetHashCode();
    }
}